<?php
if(!$_GET['cgp'] || $_GET['cgp']!='225800') {
    exit('Access Denied');
}
?>
<!DOCTYPE html>
<html>
<head lang="en">
  <meta charset="UTF-8">
  <title>产品同示例表单</title>
    <style>
        #confirm_bind{display: none;};
    </style>
</head>
<body>
<form id="ourFrm" action="" method="post">
    <h3>账号绑定验证</h3>
    <input name="action" type="hidden" value="bind"/>
    <p>account: <input type="number" name="account" /></p>
    <p>password: <input type="password" name="pwd" /> </p>
    <p><button type="button" id="BtnSubmit">Check</button></p>
</form>
<div id="confirm_bind">
    <h3>确认绑定</h3>
    <p>mid: <input type="number" name="mid" /></p>
    <button id="btnBind" type="button">Bind</button>
</div>
<div style="width:500px;border:1px solid #ddd; background-color: #B5EEAC;" id="result">

</div>
<script src="http://cdn.staticfile.org/jquery/1.9.0/jquery.min.js"></script>
<script src="/js/md5.js"></script>
<script>
    $(document).ready(function(){
        $("#BtnSubmit").on('click', function(){
            var pwd    = hex_md5($("input[name='pwd']").val()),
                params = {
                    action:'check_account',
                    account:$("input[name='account']").val(),
                    pwd:pwd
                };
            $.post('/module/sync/index.php', params,'','json')
                .done(function(res){
                    $("#result").text(res.msg);
                    if(res.status=='ok'){
                        $("#confirm_bind").show();
                        //$("#result").text(res.msg);
                    } else {
                        //$("#result").text(res.msg);
                    }
                });
        });
        $("#btnBind").on('click', function(){
            var pwd    = hex_md5($("input[name='pwd']").val()),
                params = {
                    action:'bind_account',
                    mid:$("input[name='mid']").val(),
                    account:$("input[name='account']").val(),
                    pwd:pwd
                };
            $.post('/module/sync/index.php', params,'','json')
                .done(function(res){
                    $("#result").text(res.msg);
                    if(res.status=='ok'){
                        //$("#result").text(res.msg);
                    } else {
                        //$("#result").text(res.msg);
                    }
                });
        });

    });
</script>
</body>
</html>